<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								节点名称：<input type="text" name="nodeName"/>
							</li>

							<li>
								ip地址：<input type="text" name="ip"/>
							</li>


							<li>
								节点机用户名：<input type="text" name="userName"/>
							</li>


							<li>
								客户端状态： <select id="status" name="status">
								<option value="" >全部</option>
								<option value="1" >状态正常</option>
								<option value="0" >状态异常</option>
								<option value="-1" >Jmeter已关闭</option>
							</select>
							</li>

							<li>
								系统类型： <select id="os" name="os">
								<option value="" >全部</option>
								<option value="windows" >windows</option>
								<option value="linux" >linux</option>
							</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jmeter:jmeterNode:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jmeter:jmeterNode:remove')}]];
        var prefix = ctx + "jmeter/jmeterNode";
		var casePrefix = ctx + "jmeter/jmeterTestCase";


        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "性能测试分布式节点",
				onLoadSuccess: function (data) {
						return console.log(data);
				},
				uniqueId:"id",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id',
					title : '',
					visible: false
				},
				{
					field : 'nodeName',
					title : 'Jmeter节点名称',
					sortable: true
				},
				{
					field: 'status',
					title: '客户端状态',
					width: '10%',
					class: 'myTDLengthHidden',
					formatter: function (value,
										 row, index) {
						if (value == 1) {
							var hdiv = '<span id="statusSpan' + row.id + '" class="glyphicon glyphicon-ok-sign" style="color: rgb(0, 175, 0);"> 状态正常</span>';
						} else if (value == 0) {
							var hdiv = '<span id="statusSpan' + row.id + '" class="glyphicon glyphicon-minus-sign" style="color: rgb(199, 0, 0);"> 状态异常</span>';
						} else if (value == -1) {
							var hdiv = '<span id="statusSpan' + row.id + '" class="glyphicon glyphicon-question-sign" style="color: rgba(1,6,14,0.96);"> Jmeter已关闭</span>';
						} else {
							var hdiv = '<span id="statusSpan' + row.id + '" class="glyphicon glyphicon-question-sign" style="color: rgb(255, 168, 0); font-size: 14px;"> 状态未知</span>';
						}
						return '<font id="statusFont' + row.id + '">' + hdiv + '</font>';
					}
				},
				// {
				// 	field : 'nodePort',
				// 	title : '节点端口',
				// 	sortable: true
				// },
				{
					field : 'ip',
					title : 'ip地址',
					sortable: true
				},
				{
					field : 'jmeterPort',
					title : 'Jmeter链接端口号',
					sortable: true
				},
				{
					field : 'userName',
					title : '节点机用户名',
					sortable: true
				},
				{
					field : 'passwd',
					title : '节点机密码',
					sortable: true
				},
				{
					field : 'maxConcurrency',
					title : '最大并发数 ',
					formatter:function(v,r,i){
						return v==-1?'-':v;
					},
					sortable: true
				},
				{
					field : 'cpu',
					title : 'cpu ',
					formatter:function(v,r,i){
						return v==-1?'-':v;
					},
					sortable: true
				},
				{
					field : 'memory',
					title : '内存 单位g ',
					formatter:function(v,r,i){
						return v==-1?'-':v;
					},
					sortable: true
				},
				{
					field : 'disk',
					title : '磁盘 单位g  ',
					formatter:function(v,r,i){
						return v==-1?'-':v;
					},
					sortable: true
				},
				{
					field : 'io',
					title : 'io ',
					formatter:function(v,r,i){
						return v==-1?'-':v;
					},
					sortable: true
				},
				{
					field : 'os',
					title : '操作系统',
					sortable: true
				},
				{
					field : 'homeDir',
					title : '子节点的Jmeter路径',
					sortable: true
				},
				{
					field : 'addTime',
					title : '创建时间',
					formatter: function (value,
										 row, index) {
						return $.common.formatTime(value);
					}
				},
				{
					field : 'addBy',
					title : '提交用户id',
					sortable: true
				},
				{
					field : 'updateTime',
					title : '修改时间',
					formatter: function (value,
										 row, index) {
						return $.common.formatTime(value);
					}
				},
				{
					field : 'updateBy',
					title : '修改用户id',
					sortable: true
				}

		        ]
            };
            $.table.init(options);
        });


		/*添加选择的用例到测试计划中*/
		function submitHandler(caseId,index){
			var rows = $.map($('#bootstrap-table').bootstrapTable('getSelections'), function (row) {
				return row.id;
			});


			$.modal.confirm("确认保存您选择的节点吗?", function() {

				var config = {
					url: casePrefix + "/saveCaseNode",
					type: "post",
					dataType: "json",
					contentType:"application/json",
					data: JSON.stringify({caseId:caseId,nodeIdList:rows}),
					beforeSend: function () {
					},
					success: function(result) {
						$.modal.msgSuccess(result.msg);
						$.modal.closeLoading();
						$.modal.enable();
						layer.close(index)
					}
				};
				$.ajax(config);
			});

		}

		$('#bootstrap-table').on('load-success.bs.table', function (e,data) {
			var ids=[[${nodeIdList}]];
			$('#bootstrap-table').bootstrapTable('checkBy', {field: 'id', values: ids})
		});




	</script>
</body>
</html>